package service;

public class save {
    public String user;
    public int day;
    public int hp;
    public String place;
    public int cash;
    public int bank;
    public int guangpanp;
    public int guangpanq;
    public int xiangyanp;
    public int xiangyanq;
    public int huazhuangp;
    public int huazhuangq;
    public int wanjup;
    public int wanjuq;
    public int shoujip;
    public int shoujiq;
    public int jiajiup;
    public int jiajiuq;
    public int avp;
    public int avq;
    public int qichep;
    public int qicheq;
    public int guwanp;
    public int guwanq;
    public int fangzip;
    public int fangziq;

    public static void saveToSQL(String user, String day, String hp, String place, String cash, String bank, String guangpanp, String guangpanq, String xiangyanp, String xiangyanq,
                                 String huazhuangp, String huazhuangq, String wanjup, String wanjuq, String shoujip, String shoujiq, String jiajiup, String jiajiuq,
                                 String avp, String avq, String qichep, String qicheq, String guwanp, String guwanq, String fangzip, String fangziq){
        String cmd = "UPDATE `save` SET ";
        int count = 0;
        if(day != null){
            cmd += "`day`= " + day;
            count++;
        }
        if(hp != null){
            cmd += "`hp`= " + hp;
            count++;
        }
        if(place != null){
            if(count != 0){
                cmd += ", ";
            }
            cmd += "`place`= " + place;
            count++;
        }
        if(cash != null){
            if(count != 0){
                cmd += ", ";
            }
            cmd += "`cash`= " + cash;
            count++;
        }
        if(bank != null){
            if(count != 0){
                cmd += ", ";
            }
            cmd += "`bank`= " + bank;
            count++;
        }
        if(guangpanp != null){
            if(count != 0){
                cmd += ", ";
            }
            cmd += "`guangpanp`= " + guangpanp;
            count++;
        }
        if(guangpanq != null){
            if(count != 0){
                cmd += ", ";
            }
            cmd += "`guangpanq`= " + guangpanq;
            count++;
        }
        if(xiangyanp != null){
            if(count != 0){
                cmd += ", ";
            }
            cmd += "`xiangyanp`= " + xiangyanp;
            count++;
        }
        if(xiangyanq != null){
            if(count != 0){
                cmd += ", ";
            }
            cmd += "`xiangyanq`= " + xiangyanq;
            count++;
        }
        if(huazhuangp != null){
            if(count != 0){
                cmd += ", ";
            }
            cmd += "`huazhuangp`= " + huazhuangp;
            count++;
        }
        if(huazhuangq != null){
            if(count != 0){
                cmd += ", ";
            }
            cmd += "`huazhuangq`= " + huazhuangq;
            count++;
        }
        if(wanjup != null){
            if(count != 0){
                cmd += ", ";
            }
            cmd += "`wanjup`= " + wanjup;
            count++;
        }
        if(wanjuq != null){
            if(count != 0){
                cmd += ", ";
            }
            cmd += "`wanjuq`= " + wanjuq;
            count++;
        }
        if(shoujip != null){
            if(count != 0){
                cmd += ", ";
            }
            cmd += "`shoujip`= " + shoujip;
            count++;
        }
        if(shoujiq != null){
            if(count != 0){
                cmd += ", ";
            }
            cmd += "`shoujiq`= " + shoujiq;
            count++;
        }
        if(jiajiup != null){
            if(count != 0){
                cmd += ", ";
            }
            cmd += "`jiajiup`= " + jiajiup;
            count++;
        }
        if(jiajiuq != null){
            if(count != 0){
                cmd += ", ";
            }
            cmd += "`jiajiuq`= " + jiajiuq;
            count++;
        }
        if(avp != null){
            if(count != 0){
                cmd += ", ";
            }
            cmd += "`avp`= " + avp;
            count++;
        }
        if(avq != null){
            if(count != 0){
                cmd += ", ";
            }
            cmd += "`avq`= " + avq;
            count++;
        }
        if(qichep != null){
            if(count != 0){
                cmd += ", ";
            }
            cmd += "`qichep`= " + qichep;
            count++;
        }
        if(qicheq != null){
            if(count != 0){
                cmd += ", ";
            }
            cmd += "`qicheq`= " + qicheq;
            count++;
        }
        if(guwanp != null){
            if(count != 0){
                cmd += ", ";
            }
            cmd += "`guwanp`= " + guwanp;
            count++;
        }
        if(guwanq != null){
            if(count != 0){
                cmd += ", ";
            }
            cmd += "`guwanq`= " + guwanq;
            count++;
        }
        if(fangzip != null){
            if(count != 0){
                cmd += ", ";
            }
            cmd += "`fangzip`= " + fangzip;
            count++;
        }
        if(fangziq != null){
            if(count != 0){
                cmd += ", ";
            }
            cmd += "`fangziq`= " + fangziq;
            count++;
        }
        cmd += " WHERE user = '"+user+"'";
        if(count != 0){
            sqlService.write(cmd);
        }
    }
}
